<?php

class ChangePasswordForm extends sfForm
{

	public function setup()
	{
		$this->setWidgets(array(
			'current_password' => new sfWidgetFormInputPassword(array('label' => 'Contrase&ntilde;a actual')),
			'new_password' => new sfWidgetFormInputPassword(array('label' => 'Nueva contrase&ntilde;a')),
			'confirm_password' => new sfWidgetFormInputPassword(array('label' => 'Confirmar contrase&ntilde;a'))
		));
		
		$this->setValidators(array(
			'current_password' => new sfValidatorString(),
			'new_password' => new sfValidatorString(array('min_length' => 6)),
			'confirm_password' => new sfValidatorString(array('required' => false))
		));
		
		$this->validatorSchema->offsetGet('new_password')->setMessage('min_length', 'Contrase&ntilde;a muy pequeña (%min_length% caracteres m&iacute;nimo)');
		
		$this->mergePreValidator(new sfValidatorSchemaCompare('new_password', sfValidatorSchemaCompare::EQUAL, 'confirm_password', array(), array('invalid' => 'Las contraseñas no coinciden')));
		
		$this->widgetSchema->setNameFormat('change_password[%s]');
		$this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
	}

}